import java.util.Scanner;

public class a528 {
	public static char[] reviseLength(String mainOp, String compareOp) {
		String revision = "";
		
		if(mainOp.length() < compareOp.length()) {			
			for(int i = 0; i < (compareOp.length() - mainOp.length()); i++)
				{ revision += "0"; }
			mainOp = (revision + mainOp);
		}
		
		return mainOp.toCharArray();
	}
	public static boolean positiveNumberDetermine(char[] opd1, char[] opd2) {
		boolean chop = false;
		int a, b;
		int tempOpd;
		
		for(int i = opd1.length - 1; i >= 0; i--) {
			a = Integer.parseInt(Character.toString(opd1[i]));
			b = Integer.parseInt(Character.toString(opd2[i]));
			tempOpd = (a - b);
			
			if(chop)
				{ tempOpd --; }
			
			if(tempOpd > (-1)) {
				chop = false;
			} else {
				chop = true;
			}
		}
		
		if(chop) {
			return false;
		} else {
			return true;
		}
	}
	public static boolean sortDetermine(String j, String jPlus1) {
		boolean determine = false;
		
		if(((j.toCharArray()[0] != '-') && (jPlus1.toCharArray()[0] != '-')) || ((j.toCharArray()[0] == '-') && (jPlus1.toCharArray()[0] == '-'))) {
			if((j.toCharArray()[0] != '-')) {
				if(positiveNumberDetermine(reviseLength(j, jPlus1), reviseLength(jPlus1, j)))
					determine = true;
			} else {
				j = j.substring(1, j.length());
				jPlus1 = jPlus1.substring(1, jPlus1.length());
				
				if(!(positiveNumberDetermine(reviseLength(j, jPlus1), reviseLength(jPlus1, j))))
					determine = true;
			}
		} else {
			if(((j.toCharArray()[0] != '-') && (jPlus1.toCharArray()[0] == '-')))
				{ determine = true; }
		}
		
		return determine;
	}
	public static String[] bubbleSort(String[] unsorted) {
		String tempSort;
		
		for(int i = 0; i < unsorted.length - 1; i++) {
			for(int j = 0; j < unsorted.length - 1 - i; j++) {
				if(sortDetermine(unsorted[j], unsorted[j + 1])) {
					tempSort = unsorted[j];
					unsorted[j] = unsorted[j + 1];
					unsorted[j + 1] = tempSort;
				}
			}
		}
		
		return unsorted;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input, output;
		int n;
		String[] unsorted;
		
		while(sc.hasNext()) {
			n = Integer.parseInt(sc.nextLine());
			
			unsorted = new String[n];
			
			for(int i = 0; i < n; i++) {
				input = sc.nextLine();
				unsorted[i] = input;
			}
			
			unsorted = bubbleSort(unsorted);
			
			output = "";
			for(String s : unsorted)
				{ output += (s + '\n'); }
			output = output.substring(0, output.length() - 1);
			
			System.out.println(output);
		} // next 
	} // main
}